package com.example.controller.webchat;

import com.example.dto.ZyCategoriesDTO;
import com.example.dto.webchat.CategoriesWebchatQueryDTO;
import com.example.model.api.Result;
import com.example.service.CategoriesService;
import com.example.validator.ValidatorUtils;
import com.example.validator.group.AddGroup;
import com.example.validator.group.DefaultGroup;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Tag(name = "小程序点单")
@RequestMapping("webchat/categories")
public class CategoriesWebchatController {

    @Autowired
    private CategoriesService categoriesService;

    @PostMapping("list")
    @Operation(summary = "列表", description = "点单列表")
    public Result<List<ZyCategoriesDTO>> list(@RequestBody CategoriesWebchatQueryDTO categoriesWebchatQueryDTO) {
        ValidatorUtils.validateEntity(categoriesWebchatQueryDTO, DefaultGroup.class);

        List<ZyCategoriesDTO> zyCategoriesDTOS = categoriesService.categoriesGoodByStoreTenent(categoriesWebchatQueryDTO);
        return new Result<List<ZyCategoriesDTO>>().ok(zyCategoriesDTOS);
    }
}
